package org.rambadger.command.event;

import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;
import org.rambadger.command.validation.UrlIdentifier;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * Event representing a change of the Email account belonging to a {@link org.rambadger.command.model.UserAggregate User}
 */
public class UserEmailChanged implements Serializable {
    private static final long serialVersionUID = 4506184753160007874L;

    private final String username;
    private final String emailAddress;

    /**
     * Instantiates a new event.
     *
     * @param username the username
     * @param email the new email address
     */
    public UserEmailChanged(String username, String email) {
        this.username = username;
        this.emailAddress = email;
    }

    /**
     * Gets the username.
     *
     * @return the username
     */
    @UrlIdentifier @NotNull
    public String getUsername() {
        return username;
    }

    /**
     * Gets the new email address.
     *
     * @return the new email address
     */
    @Email @NotBlank
    public String getEmailAddress() {
    return emailAddress;
    }

    @Override
    public String toString() {
        return "UserEmailChanged{" +
                "username='" + username + '\'' +
                ", emailAddress='" + emailAddress + '\'' +
                '}';
    }
}
